//
//  ByNetModel.m
//  caipiao_ios
//
//  Created by mc on 2018/7/13.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByNetModel.h"

@implementation ByNetModel

- (void)setAttributes:(NSDictionary *)jsonDic{
    [super setAttributes:jsonDic];
    self.ID = [NSString stringWithFormat:@"%@", jsonDic[@"id"]];
    self.score_a = jsonDic[@"-1-a"];
    self.score_d = jsonDic[@"-1-d"];
    self.score_h = jsonDic[@"-1-h"];
    
    self.score0000 = jsonDic[@"0000"];
    self.score0001 = jsonDic[@"0001"];
    self.score0002 = jsonDic[@"0002"];
    self.score0003 = jsonDic[@"0003"];
    self.score0004 = jsonDic[@"0004"];
    self.score0005 = jsonDic[@"0005"];
    self.score0100 = jsonDic[@"0100"];
    self.score0101 = jsonDic[@"0101"];
    self.score0102 = jsonDic[@"0102"];
    self.score0103 = jsonDic[@"0103"];
    self.score0104 = jsonDic[@"0104"];
    self.score0105 = jsonDic[@"0105"];
    self.score0200 = jsonDic[@"0200"];
    self.score0201 = jsonDic[@"0201"];
    self.score0202 = jsonDic[@"0202"];
    self.score0203 = jsonDic[@"0203"];
    self.score0204 = jsonDic[@"0204"];
    self.score0205 = jsonDic[@"0205"];
    self.score0300 = jsonDic[@"0300"];
    self.score0301 = jsonDic[@"0301"];
    self.score0302 = jsonDic[@"0302"];
    self.score0303 = jsonDic[@"0303"];
    self.score0400 = jsonDic[@"0400"];
    self.score0401 = jsonDic[@"0401"];
    self.score0402 = jsonDic[@"0402"];
    self.score0500 = jsonDic[@"0500"];
    self.score0501 = jsonDic[@"0501"];
    self.score0502 = jsonDic[@"0502"];
    
    
    self.moneyType = jsonDic[@"type"];
    
    
    if (jsonDic[@"play_game"]) {
        self.play_gameArray = jsonDic[@"play_game"];
        if (self.play_gameArray.count > 0) {
             self.play_game = [self getPlayGameStringWithArray:self.play_gameArray];
        }
    }
    
    self.timeString = jsonDic[@"b_date"];
}

- (NSString *)getPlayGameStringWithArray:(NSArray *)array{
    NSString *playGame = @"";
    NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:1];
    for (NSString *value in array) {
        if (value.integerValue == 1) {
            [tempArray addObject:@"单关"];
        }else{
            [tempArray addObject:[NSString stringWithFormat:@"%@串1",value]];
        }
    }
    
    playGame = [tempArray componentsJoinedByString:@", "];
    
    return playGame;
    
}



- (void)setSpfArray:(NSMutableArray *)spfArray{
    _spfArray = spfArray;
    self.selectedSpfArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:spfArray];
    if (self.selectedSpfArray.count > 0) {
        self.selectedSpfString = [[self getTitleArray:self.selectedSpfArray] componentsJoinedByString:@"  "];
    }
}

- (void)setRspfArray:(NSMutableArray *)rspfArray{
    _rspfArray = rspfArray;
    self.selectedRSpfArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:rspfArray];
    if (self.selectedRSpfArray) {
        self.selectedRSpfString = [[self getTitleArray:self.selectedRSpfArray] componentsJoinedByString:@"  "];
    }
}


- (void)setScoresArray:(NSMutableArray *)scoresArray{
    _scoresArray = scoresArray;
    self.selectedScoresArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:scoresArray];
    if (self.selectedScoresArray.count > 0) {
        self.selectedScoresString = [[self getTitleArray:self.selectedScoresArray] componentsJoinedByString:@"  "];
    }
    
    NSArray *array1 = [scoresArray subarrayWithRange:NSMakeRange(0, 13)];
    NSArray *array2 = [scoresArray subarrayWithRange:NSMakeRange(13, 5)];
    NSArray *array3 = [scoresArray subarrayWithRange:NSMakeRange(18, 13)];
    self.selectedSScoresArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:array1];
    self.selectedPScoresArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:array2];
    self.selectedFScoresArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:array3];
    
    if (self.self.selectedSScoresArray.count > 0) {
        self.selectedSScoresString = [[self getTitleArray:self.selectedSScoresArray] componentsJoinedByString:@"  "];
    }
  
    if (self.self.selectedPScoresArray.count > 0) {
        self.selectedPScoresString = [[self getTitleArray:self.selectedPScoresArray] componentsJoinedByString:@"  "];
    }
    if (self.self.selectedFScoresArray.count > 0) {
        self.selectedFScoresString = [[self getTitleArray:self.selectedFScoresArray] componentsJoinedByString:@"  "];
    }
}

- (void)setHalfAllArray:(NSMutableArray *)halfAllArray{
    _halfAllArray = halfAllArray;
    self.selectedHalfAllArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:halfAllArray];
    if (self.selectedHalfAllArray.count > 0) {
        self.selectedHalfAllString = [[self getTitleArray:self.selectedHalfAllArray] componentsJoinedByString:@"  "];
    }
}

- (void)setGoalsArray:(NSMutableArray *)goalsArray{
    _goalsArray = goalsArray;
    self.selectedGoalsArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:goalsArray];
    if (self.selectedGoalsArray.count > 0) {
        self.selectedGoalsString = [[self getTitleArray:self.selectedGoalsArray] componentsJoinedByString:@"  "];
    }
}



- (void)setSelectedSpfArray:(NSArray *)selectedSpfArray{
    _selectedSpfArray = selectedSpfArray;
    if (selectedSpfArray.count > 0) {
        self.selectedSpfString = [[self getTitleArray:selectedSpfArray] componentsJoinedByString:@"  "];
    }
}

- (void)setSelectedRSpfArray:(NSArray *)selectedRSpfArray{
    _selectedRSpfArray = selectedRSpfArray;
    if (selectedRSpfArray) {
        self.selectedRSpfString = [[self getTitleArray:self.selectedRSpfArray] componentsJoinedByString:@"  "];
    }
}


- (void)setSelectedScoresArray:(NSArray *)selectedScoresArray{
    _selectedScoresArray = selectedScoresArray;
    if (selectedScoresArray.count > 0) {
        self.selectedScoresString = [[self getTitleArray:selectedScoresArray] componentsJoinedByString:@"  "];
    }
}


- (void)setSelectedHalfAllArray:(NSArray *)selectedHalfAllArray{
    _selectedHalfAllArray = selectedHalfAllArray;
    if (selectedHalfAllArray.count > 0) {
        self.selectedHalfAllString = [[self getTitleArray:selectedHalfAllArray] componentsJoinedByString:@"  "];
    }
}

- (void)setSelectedGoalsArray:(NSArray *)selectedGoalsArray{
    _selectedGoalsArray = selectedGoalsArray;
    if (selectedGoalsArray.count > 0) {
        self.selectedGoalsString = [[self getTitleArray:selectedGoalsArray] componentsJoinedByString:@"  "];
    }
}

- (NSMutableArray *)getTitleArray:(NSArray *)selectedArray{
    NSMutableArray *array = [NSMutableArray arrayWithCapacity:1];
    for (ByNetModel *netModel in selectedArray) {
        [array addObject:[NSString stringWithFormat:@"%@(%@)",netModel.title,netModel.valueString]];
    }
    return array;
}



- (id)copyWithZone:(NSZone *)zone{
    ByNetModel *model = [[self class] allocWithZone:zone];
    unsigned int count = 0;
    objc_property_t *properties = class_copyPropertyList([ByNetModel class], &count);
    for (int i = 0; i < count; i++) {
        const char *name = property_getName(properties[i]);
        NSString *propertyName = [NSString stringWithUTF8String:name];
        id propertyValue = [self valueForKey:propertyName];
        if (propertyValue) {
            [model setValue:propertyValue forKey:propertyName];
        }
        
    }
    free(properties);
    return model;
}


//篮球相关
- (void)setSfArray:(NSMutableArray *)sfArray{
    _sfArray = sfArray;
    self.sfSelectedArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:sfArray];
    if (self.sfSelectedArray.count > 0) {
        self.selectedSfString = [[self getTitleArray:self.sfSelectedArray] componentsJoinedByString:@"  "];
        
    }
}

- (void)setRsfArray:(NSMutableArray *)rsfArray{
    _rsfArray = rsfArray;
    self.rsfSelectedArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:_rsfArray];
    if (self.rsfSelectedArray.count > 0) {
        self.selectedRsfString = [[self getTitleArray:self.rsfSelectedArray] componentsJoinedByString:@"  "];
        
    }
}

- (void)setBigSmallArray:(NSMutableArray *)bigSmallArray{
    _bigSmallArray = bigSmallArray;
    self.bigSmallSelectedArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:_bigSmallArray];
    if (self.bigSmallSelectedArray.count > 0) {
        self.selectedBigSmallString = [[self getTitleArray:self.bigSmallSelectedArray] componentsJoinedByString:@"  "];
    }
}

- (void)setSfcArray:(NSMutableArray *)sfcArray{
    _sfcArray = sfcArray;
    self.sfcSelectedArray = [ByLotteryAlgorithmHandle getSelectedDataWithArray:_sfcArray];
    if (self.sfcSelectedArray.count > 0) {
        self.selectedSfcString = [[self getTitleArray:self.sfcSelectedArray] componentsJoinedByString:@"  "];
    }
    
    
    NSArray *array1 = [sfcArray subarrayWithRange:NSMakeRange(0, 6)];
    NSArray *array2 = [sfcArray subarrayWithRange:NSMakeRange(6, 6)];
   
    self.sfcSelectedArray1 = [ByLotteryAlgorithmHandle getSelectedDataWithArray:array1];
    self.sfcSelectedArray2 = [ByLotteryAlgorithmHandle getSelectedDataWithArray:array2];
    
    
    if (self.sfcSelectedArray1.count > 0) {
        self.sfcSelectedString1 = [[self getTitleArray:self.sfcSelectedArray1] componentsJoinedByString:@"  "];
    }
    
    if (self.sfcSelectedArray2.count > 0) {
        self.sfcSelectedString2 = [[self getTitleArray:self.sfcSelectedArray2] componentsJoinedByString:@"  "];
    }
    
    
    NSLog(@"sfcSelectedString1 = %@,sfcSelectedString2 = %@", self.sfcSelectedString1,self.sfcSelectedString2);
    
}




- (void)configSize {
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont systemFontOfSize:15];
    titleLabel.numberOfLines = 0;
    titleLabel.text = self.bet_Content; // 投注
    UILabel *sourceLabel = [[UILabel alloc] init];
    sourceLabel.font = [UIFont systemFontOfSize:12];
    sourceLabel.text = self.game_Result; // 赛果
    sourceLabel.numberOfLines = 0;

    CGSize sizeOne = [titleLabel sizeThatFits:CGSizeMake(SCREEN_WIDTH/3, titleLabel.height)];
    
    CGSize sizeTwo = [sourceLabel sizeThatFits:CGSizeMake(SCREEN_WIDTH/3, sourceLabel.height)];

    self.betHight = sizeOne.height;
    self.gameHight = sizeTwo.height;

    
}



@end
